#
# This uses $1, ETOYS_GIT, which must be a git clone argument
#   to checkout and build the EToys tarball.
# $2, ETOYS_SOURCE, is used to check that the built tarball has
#   the same name as expected 
#

ETOYS_GIT=$1
ETOYS_SOURCE=$2

TMP=$(mktemp -d)

pushd $TMP
git clone ${ETOYS_GIT} etoys-git
cd etoys-git
./autogen.sh
make etoys-src
if [ -e ${ETOYS_SOURCE} ]; then
   popd
   cp $TMP/etoys-git/${ETOYS_SOURCE} .
   rm -rf $TMP
else
   echo "ERROR: ${ETOYS_SOURCE} was not built"
   echo "These were the etoys tar.gz's actually built:"
   ls -1 etoys-*.tar.gz
   echo "Not deleting $TMP/etoys-git" 
   exit 3
fi
